package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.IdentityType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * Created by Huqin on 2020/4/16
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "user_auth")
public class UserAuthEntity extends BaseEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(name = "user_id", columnDefinition = ("varchar(40) not null comment '用户id'"))
    private String userId;

    @ManyToOne
    @JoinColumn(name = "user_id", insertable = false, updatable = false)
    private UserEntity user;

    @Column(columnDefinition = ("varchar(32) not null comment '登录类型'"))
    @Enumerated(EnumType.STRING)
    private IdentityType identityType;

    @Column(columnDefinition = ("varchar(40) not null comment '标识'"))
    private String identifier;

    @Column(columnDefinition = ("varchar(40) not null comment '密码凭证'"))
    private String credential;

}
